package com.study.graph.repository;

import com.study.graph.model.NebulaResult;
import com.study.graph.model.PlayerVertex;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class PersonRepository extends BaseGraphRepository<PlayerVertex> {


    public void queryById(String id) {
        String stmt = "MATCH (m)-[e]->(n) " +
                "WHERE id(m)==\"" + id + "\"  " +
                "RETURN m,e,n";
        NebulaResult<PlayerVertex> result = super.queryObject(stmt, PlayerVertex.class);
        System.out.println(result);
    }


    @Data
    public static class QueryByNameResponse{
        private PlayerVertex v;
    }
    public void queryByName(String name) {
        String stmt = "MATCH (v:player) " +
                "where v.player.name =='" + name + "' " +
                "RETURN v ";
        NebulaResult<QueryByNameResponse> result = super.queryObject(stmt, QueryByNameResponse.class);
        System.out.println(result);
    }

    public void query() {
        String stmt = "MATCH (v:player) -[*0]-> (v2) " +
                "RETURN v,v2;";
        NebulaResult<PlayerVertex> result = super.queryObject(stmt, PlayerVertex.class);
        System.out.println(result);
    }

}
